package secure

import (
	"crypto/hmac"
	"crypto/md5"
	"crypto/sha256"
	"encoding/hex"
)

func Hmac_md5(data, key []byte) []byte {
	hmac := hmac.New(md5.New, key)
	hmac.Write(data)
	return hmac.Sum([]byte(""))
}

func Hmac_sha256(data, key []byte) []byte {
	hmac := hmac.New(sha256.New, key)
	hmac.Write(data)
	return hmac.Sum([]byte(""))
}

func Hmac_md5_hex(data, key []byte) string {
	return hex.EncodeToString(Hmac_md5(data, key))
}

func Hmac_sha256_hex(data, key []byte) string {
	return hex.EncodeToString(Hmac_sha256(data, key))
}
